#include "DeleteAction.h"
#include "EditorCore/Traversers/ChildrenFirstEntityTraverser.h"

namespace editor_core {

	DeleteAction::DeleteAction( IEntity* entity ) :
		m_entity( entity )
	{
		m_deleter = new HierarchyDeleter();
	}

	DeleteAction::~DeleteAction() {
		delete m_deleter;
	}

	bool DeleteAction::Commit() {
		ChildrenFirstEntityTraverser traverser;
		traverser.Traverse( m_entity, m_deleter );
		m_deleter->DeleteHierarchy();
		return true;
	}

	void DeleteAction::Rollback() {
		m_deleter->UndeleteHierarchy();
	}

	void DeleteAction::Recommit() {
		m_deleter->DeleteHierarchy();
	}
}
